﻿using System;
using Client.ViewModels;
using Contracts.Entities;
using Model.Movie;
using Model.MovieElements;

namespace Client.Processes
{
    public class ReadMovie
    {
        private ReadMovieItem movieReader;
        private ReadMovieElements actorReader;

        /// <summary>
        /// Bei jedem laden eines Movies werden für die AutoCompleteBox benötigten Entitäten geladen
        /// </summary>
        public ReadMovie()
        {
            this.movieReader = new ReadMovieItem();
            this.actorReader = new ReadMovieElements();

            actorReader.OnCompleted += m => ActorsViewModel.Default.Items = m;
            movieReader.OnCompleted += m => OnCompleted(m);
        }

        public void Process(int id)
        {
            movieReader.Process(id);
            actorReader.ReadActors();
        }

        public event Action<MovieItem> OnCompleted = delegate { };
    }
}
